package com.usian.controller;

import com.uaisn.pojo.User;
import com.usian.service.UserService;
import org.bouncycastle.math.Primes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@RefreshScope
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${config.info}")
    private String configInfo;


    @RequestMapping("/findById/{id}/{name}")
    public User findById(@PathVariable Integer id ,@PathVariable String name){
        System.out.println(configInfo);
        System.out.println(name);
        return userService.findById(id);
    }

    @GetMapping("/findByIdd")
    public User findByIdd(@RequestParam Integer id,String name){

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name);
        return userService.findById(id);
    }


    @PostMapping("/findByUser")
    public User findByUser(@RequestBody User user){
        System.out.println(user.toString());
        return userService.findById(user.getId());
    }

}
